package com.takeaway.presenter

import com.google.gson.Gson
import com.takeaway.model.beans.User
import com.takeaway.model.net.ResponseInfo
import com.takeaway.ui.activity.LoginActivity
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response

class LoginActivityPresenter(val loginActivity: LoginActivity): NetPresenter() {
    override fun errorCallBack() {
        loginActivity.loginFaile()
    }


    //手机号码登录的业务
    fun loginByPhone(phone: String) {
        val loginCall = takeoutService.loginByPhone(phone)
        loginCall.enqueue(callBack)
    }

    override fun parserJson(data: String) {
        // Gson 解析数据 判断逻辑

        val user = Gson().fromJson<User>(data, User::class.java)

        loginActivity.loginDataSuccess()
    }
}